package demo02;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;

public class test1 {
	 public static void main(String[] args) {
	        ArrayList<String> studentList = new ArrayList<>();

	        try (BufferedReader br = new BufferedReader(new FileReader("names.txt"))) {
	            String line;
	            while ((line = br.readLine()) != null) {
	                studentList.add(line);
	            }
	        } catch (IOException e) {
	            e.getMessage();
	        }
	            Random random = new Random();
	            int randomIndex = random.nextInt(studentList.size());
	            String randomStudent = studentList.get(randomIndex);
	            System.out.println("随机学生为: " + randomStudent);
	        }
}
